import { log } from 'console'
import React, { Component } from 'react'
interface ISate{
    show:boolean,
}
export default class app extends Component<any,ISate> {
    state={
        show:true
    }
  render() {
    return (
      <div>抽屉功能
         <Navbar title="首页" cb={()=>{console.log('子传父触发');
         this.setState({
            show:!this.state.show
         })
         }}></Navbar>
        { this.state.show &&<Sidebar></Sidebar>}
      </div>
     
    )
  }
}
//对属性进行约束
interface IProps{
    title:string,
    cb:()=>void
}
class Navbar extends Component<IProps,any>{
    render(){
        return <div>navbar
            <button onClick={()=>{
                this.props.cb()
            }}>抽屉切换</button>
        </div>
    }
}

class Sidebar extends Component{
    render(){
        return <div>sider</div>
    }
}